package com.timothy.remote.client;

import java.io.Serializable;

import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.CachingSessionDAO;

import com.timothy.remote.core.RemoteServiceInterface;

/**
 * <p>
 * User: Zhang Kaitao
 * <p>
 * Date: 14-3-13
 * <p>
 * Version: 1.0
 */
public class ClientSessionDAO extends CachingSessionDAO {

	private RemoteServiceInterface remoteService;

	public void setRemoteService(RemoteServiceInterface remoteService) {
		this.remoteService = remoteService;
	}

	@Override
	protected void doDelete(Session session) {
		remoteService.deleteSession(session);
	}

	@Override
	protected void doUpdate(Session session) {
		remoteService.updateSession(session);
	}

	@Override
	protected Serializable doCreate(Session session) {
		Serializable sessionId = remoteService.createSession(session);
		assignSessionId(session, sessionId);
		return sessionId;
	}

	@Override
	protected Session doReadSession(Serializable sessionId) {
		return remoteService.getSession(sessionId);
	}
}
